/**
 * Copyright 2005 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.edi.db;

import java.math.BigDecimal;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class PreparedEql {
	public String eql;
	private Integer currentPage;
	private Integer pageSize; 

	private Map<Integer, PreparedParam> preparedObjects;

	public PreparedEql() {
		preparedObjects = new HashMap<Integer, PreparedParam>();
	}
	
	public PreparedEql(String eql) {		
		this();
		this.eql = eql;
	}
	
	/**
	 * 清除参数，在重新为Eql赋参数前使用
	 */
	public void clearParam(){
		preparedObjects.clear();
	}
	
	/**
	 * 获得参数总数
	 * @return
	 */
	public int getParamsCount(){
		return this.preparedObjects.size();
	}
	
	public Set getParamIndexs(){
		return preparedObjects.keySet();
	}
	
	public Collection<PreparedParam> getParams(){
		return preparedObjects.values();
	}

	public void setString(int index, String fieldValue) {
		preparedObjects.put(new Integer(index), new PreparedParam(index,
				fieldValue, EdiDb.STRING));
	}
	
	public void setInt(int index,int fieldValue){
		preparedObjects.put(new Integer(index), new PreparedParam(index,
				fieldValue,EdiDb.INTEGER));
	}
	
	public void setFloat(int index,float fieldValue){
		preparedObjects.put(new Integer(index), new PreparedParam(index,
				fieldValue,EdiDb.FLOAT));
	}
	
	public void setText(int index,String fieldValue){
		preparedObjects.put(new Integer(index), new PreparedParam(index,
				fieldValue,EdiDb.TEXT));
	}
	
	public void setCurrency(int index,BigDecimal fieldValue){
		preparedObjects.put(new Integer(index), new PreparedParam(index,
				fieldValue,EdiDb.CURRENCY));
	}
	
	public void setBoolean(int index,boolean fieldValue){
		preparedObjects.put(new Integer(index), new PreparedParam(index,
				fieldValue,EdiDb.BOOLEAN));
	}
	
	public void setDateTime(int index,Date fieldValue){
		preparedObjects.put(new Integer(index), new PreparedParam(index,
				fieldValue,EdiDb.DATE));
	}
	
	public void setTime(int index,Time fieldValue){
		preparedObjects.put(new Integer(index), new PreparedParam(index,
				fieldValue,EdiDb.TIME));
	}
	
	public void setTimeStamp(int index,Timestamp fieldValue){
		preparedObjects.put(new Integer(index), new PreparedParam(index,
				fieldValue,EdiDb.TIMESTAMP));
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(Integer currentPageIndex) {
		this.currentPage = currentPageIndex;
	}
 
}
